<script>
import EasyPlayer from "@/views/witness/components/Object3D/easyPlayer";
import { handleAlarm } from "@/api/pageLiveWitness";
export default {
  filters: {
    scfsFilter(key) {
      const dataMap = {
        1: "资格预审",
        2: "资格后审"
      };
      return dataMap[key];
    },
    zbfsFilter(key) {
      const dataMap = {
        1: "公开招标",
        2: "邀请招标"
      };
      return dataMap[key];
    },
    xmlxFilter(key) {
      const dataMap = {
        A01: "房建",
        A02: "市政",
        A03: "公路",
        A04: "铁路",
        A06: "水运",
        A07: "水利",
        A0801: "煤炭",
        A0802: "石油",
        A0803: "天然气",
        A0804: "电力",
        A0805: "新能源",
        A09: "邮电通信",
        A12: "矿产冶金",
        A13: "信息网络",
        A9901: "林业",
        A9902: "农业",
        A9903: "其他"
      };
      return dataMap[key];
    }
  },
  data() {
    return {
      // show:true,
      innerVisible:false,
      Rules:{},
      Form: {
        alarmAddress: "",
        alarmContent: "",
        bidName: "",
        personName: "",
        alarmTime: "",
        alarmName: "",
        status: 0,
        content: "",
        deviceId: "",
        id:''
      }
    };
  },
  components: {
    EasyPlayer
  },
  methods: {
    setForm(form) {
      this.Form = { ...form };
    },
    handleOpenBofang(val) {
      // console.log(val);
      
      // 获取视频地址
      // getAlarmPlaybackURLs({"deviceId": "","alarmId": ""}).then(res=>{
      //   console.log('res');
      // this.innerVisible = true;
      // })
    },
    submitData() {
      const { id, status, content } = this.Form;
      handleAlarm({ id, status, content }).then((res) => {
        console.log("send", res);
        if(res.code === 0 && res.success){
          this.$message.success('处理成功')
          this.$emit('update:visible', false)
        } 
      });
    }
  }
};
</script>
<template>
  <!-- 项目信息  -->
  <el-dialog
    v-bind="$attrs"
    :before-close="() => $emit('update:visible', false)"
    :show-close="true"
    width="700px"
  >
    <el-form ref="Form" :model="Form" :rules="Rules" label-width="auto">
      <el-form-item label="姓名">
        {{ Form.personName }}
      </el-form-item>
      <el-form-item label="标段">
        {{ Form.bidName }}
      </el-form-item>
      <el-form-item label="时间">
        <span>{{ Form.alarmTime }}</span>
        <span style="margin-left: 50px">位置：{{ Form.alarmAddress }}</span>
        <span style="margin-left: 50px">类型：{{ Form.alarmName }}</span>
      </el-form-item>
      <el-form-item label="描述">
        <span>{{ Form.alarmContent }}</span>
      </el-form-item>
      <el-form-item label="是否处理">
        <el-radio-group v-model="Form.status">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="处理意见">
        <el-input
          type="textarea"
          :autosize="{ minRows: 3, maxRows: 5 }"
          placeholder="请输入内容"
          maxlength="100"
          show-word-limit
          v-model="Form.content"
        ></el-input>
      </el-form-item>
      <el-form-item label="视频查看" v-if="Form.deviceId">
        <el-button type="primary" size="mini" @click="handleOpenBofang(Form.deviceId)">播放</el-button>
      </el-form-item>
    </el-form>
    <span slot="footer" v-if="$attrs.title !=='预警详情'" class="dialog-footer">
      <el-button type="primary" @click="submitData('gbForm')">确定</el-button>
      <el-button @click="$emit('update:visible', false)">取消</el-button>
    </span>
    <el-dialog width="33.3%" title="播放视频" :visible.sync="innerVisible" append-to-body>
      <EasyPlayer style="height: 300px" src="" />
    </el-dialog>
  </el-dialog>
</template>
<style scoped lang="scss">
::v-deep .el-form-item__content {}
</style>
